<?php



/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Game
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
 
class Game_Form_Admin_Level extends Authorization_Form_Admin_Level_Abstract
{
  
  public function init()
  {
    parent::init();
    
    $this
      ->setTitle('Member Level Settings')
      ->setDescription("These settings are applied on a per member level basis. Start by selecting the member level you want to modify, then adjust the settings for that level below.");
      
    $this->addElement('Radio', 'view', array(
      'label' => 'Allow Viewing of Games?',
      'description' => 'Do you want to let members view games? If set to no, some other settings on this page may not apply.',
      'multiOptions' => array(
        2 => 'Yes, allow viewing of all games, even private ones.',
        1 => 'Yes, allow viewing of games.',
        0 => 'No, do not allow games to be viewed.',
      ),
      'value' => ( $this->isModerator() ? 2 : 1 ),
    ));
    if( !$this->isModerator() ) {
      unset($this->view->options[2]);
    }
    
    if( !$this->isPublic() ) 
    {
      
	    $this->addElement('Radio', 'create', array(
	      'label' => 'Allow Creation of Games?',
	      'description' => 'Do you want to let members create games? If set to no, some other settings on this page may not apply.',
	      'multiOptions' => array(
	        1 => 'Yes, allow creation of games.',
	        0 => 'No, do not allow games to be created.'
	      ),
	      'value' => 1,
	    ));    
	    
	    $this->addElement('Radio', 'edit', array(
	      'label' => 'Allow Editing of Games?',
	      'description' => 'Do you want to let members edit games? If set to no, some other settings on this page may not apply.',
	      'multiOptions' => array(
	        2 => 'Yes, allow members to edit all games.',
	        1 => 'Yes, allow members to edit their own games.',
	        0 => 'No, do not allow members to edit their games.',
	      ),
	      'value' => ( $this->isModerator() ? 2 : 1 ),
	    ));
      if( !$this->isModerator() ) {
        unset($this->edit->options[2]);
      }
      
	    $this->addElement('Radio', 'delete', array(
	      'label' => 'Allow Deletion of Games?',
	      'description' => 'Do you want to let members delete games? If set to no, some other settings on this page may not apply.',
	      'multiOptions' => array(
	        2 => 'Yes, allow members to delete all games.',
	        1 => 'Yes, allow members to delete their own games.',
	        0 => 'No, do not allow members to delete their games.',
	      ),
	      'value' => ( $this->isModerator() ? 2 : 1 ),
	    ));
      if( !$this->isModerator() ) {
        unset($this->delete->options[2]);
      }
			
	    $this->addElement('Radio', 'published', array(
	      'label' => 'Published Game on Creation?',
	      'description' => 'Would you like to set game status as "Published" when members submit new games?',
	      'multiOptions' => array(
	        1 => 'Yes, set game status as "Published".',
	        0 => 'No, set game status as "Pending" for manual admin approval.'
	      ),
	      'value' => 1,
	    ));
      
      // Element: comment
      $this->addElement('Radio', 'comment', array(
        'label' => 'Allow Commenting on Games?',
        'description' => 'Do you want to let members of this level comment on games?',
        'multiOptions' => array(
          2 => 'Yes, allow members to comment on all games, including private ones.',
          1 => 'Yes, allow members to comment on games.',
          0 => 'No, do not allow members to comment on games.',
        ),
        'value' => ( $this->isModerator() ? 2 : 1 ),
      ));
      if( !$this->isModerator() ) {
        unset($this->comment->options[2]);
      }

	    // PRIVACY ELEMENTS
	    $this->addElement('MultiCheckbox', 'auth_view', array(
	      'label' => 'Games View Privacy',
	      'description' => 'Your members can choose from any of the options checked below when they decide who can see their games. If you do not check any options, everyone will be allowed to view games.',
				'multiOptions' => array(
				  'everyone'            => 'Everyone',
				  'registered'          => 'Registered Members',
				  'owner_network'       => 'Friends and Networks',
				  'owner_member_member' => 'Friends of Friends',
				  'owner_member'        => 'Friends Only',
				  'owner'               => 'Just Me'
				),
				'value' => array('everyone', 'registered', 'owner_network','owner_member_member', 'owner_member', 'owner')
	    ));
	
	    $this->addElement('MultiCheckbox', 'auth_comment', array(
	      'label' => 'Game Comment Options',
	      'description' => 'Your members can choose from any of the options checked below when they decide who can post comments on their games. If you do not check any options, everyone will be allowed to post comments on games.',
				'multiOptions' => array(
				  'registered'          => 'Registered Members',
				  'owner_network'       => 'Friends and Networks',
				  'owner_member_member' => 'Friends of Friends',
				  'owner_member'        => 'Friends Only',
				  'owner'               => 'Just Me'
				),
				'value' => array('registered', 'owner_network','owner_member_member', 'owner_member', 'owner')
	    ));	 
   

      $this->addElement('Text', 'max_games', array(
        'label' => 'Maximum Allowed Games',
        'description' => 'Enter the maximum number of allowed games. The field must contain an integer, use zero for unlimited.',
        'class' => 'short',
        'validators' => array(
          array('Int', true),
          new Engine_Validate_AtLeast(0),
        ),
      ));
      
    } // end isPublic()
  }

}